/***************************************************
> Copyright (C) 2023 ==KINGYI== All rights reserved.
> File Name: 03虚继承.cpp
> Author: Kingyi
> Mail:joseph2009@163.com 
> Created Time: 2023年07月25日 星期二 16时06分01秒
***************************************************/

#include <iostream>

using namespace std;

class Human  //虚基类
{
	public:
		Human();
		Human(string);
		void display();
	private:
		string name;
};

//虚继承
class Father:virtual public Human
{
	public:
		Father();
		Father(string);
		Father(string,string);
		void display();
	private:
		string work;
};

//虚继承
class Mother:virtual public Human
{
	public:
		Mother();
		Mother(string);
		Mother(string,string);
		void display();
	private:
		string job;
};

class Child:public Father,public Mother
{
	public:
		Child();
		Child(string,string,string,string);
		void display();
	private:
		string study;
};

Human::Human()
{
	cout << "Human::Human()" << endl;
}
	
Human::Human(string name)
{
	cout <<"Human::Human(string)" << endl;
	this->name = name;
}
		
void Human::display()
{
	cout << name;
}


Father::Father()
{
	cout << "Father::Father()" << endl;
}

Father::Father(string work)
{
	cout <<"Father::Father(string)" << endl;
	this->work = work;
}

Father::Father(string name,string work):Human(name)
{
	cout << "Father::Father(string,string)" << endl;
	this->work = work;
}

void Father::display()
{
	cout << work;
}

Mother::Mother()
{
	cout << "Mother::Mother()" << endl;
}

Mother::Mother(string job)
{
	cout <<"Mother::Mother(string)" << endl;
	this->job = job;
}
Mother::Mother(string name,string job):Human(name)
{
	cout << "Mother::Mother(string,string)" << endl;
	this->job = job;

}

void Mother::display()
{
	cout << job;
}

Child::Child()
{
	cout <<"Child::Child()" << endl;
}

//Child::Child(string name,string work,string job,string study):Father(name,work),Mother(name,job)
//Child::Child(string name,string work,string job,string study):Father(name,work),Mother(name,job),Human(name)
Child::Child(string name,string work,string job,string study):Father(work),Mother(job),Human(name)
{
	cout <<"Child::Child(string,string,string,string)" << endl;
	this->study = study;
}

void Child::display()
{
	cout << study;
}

int main(int argc,const char* argv[])
{

	Child c("小屁孩","吃饭","睡觉","打豆豆");
    return 0;
}
